; Published under the MIT License

; Copyright(c) 2010 Ajtaji and Zenner
 
; Permission is hereby granted, free of charge, To any person obtaining a copy
; of this software And associated documentation files(the "Software"), To deal
; in the Software without restriction, including without limitation the rights
; To use, copy, modify, merge, publish, distribute, sublicense, And/Or sell
; copies of the Software, And To permit persons To whom the Software is
; furnished To do so, subject To the following conditions : 
 
; The above copyright notice And this permission notice shall be included in
; all copies Or substantial portions of the Software.
 
; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS Or
; IMPLIED, INCLUDING BUT Not LIMITED To THE WARRANTIES OF MERCHANTABILITY, 
; FITNESS For A PARTICULAR PURPOSE And NONINFRINGEMENT.IN NO EVENT SHALL THE
; AUTHORS Or COPYRIGHT HOLDERS BE LIABLE For ANY CLAIM, DAMAGES Or OTHER
; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT Or OTHERWISE, ARISING FROM, 
; OUT OF Or IN CONNECTION With THE SOFTWARE Or THE USE Or OTHER DEALINGS IN
; THE SOFTWARE.
      

Structure GLWindowInfo
  Name.s
  x.l
  y.l
  Bits.l
  Fullscreen.l
EndStructure



Structure IMAGE ;Image Type - Contains Height, Width and Data
  sizeX.l
  sizeY.l
  Data.l
EndStructure
Structure SpriteInfo
  ImageNumber.l; Image that this sprite is actually using
  x.l ;x location on screen
  y.l ;y location on screen
  UsingAlpha.l ; Is this sprite going to use Alpha?
  TransparentColor.l ; What is this sprites' transparent color?
  ;IsBeingDisplayed : 0 = yes(draw), 1 = no(dont draw)
  IsBeingDisplayed.l ; is this sprite gonna get pasted this round?
  alpha.l
  OffsetX.l
  OffsetY.l
  ; x.l
  ; y.l
  z.l
  rotation.l
  ;MaskList.l
  image.l
  ImageList.l
  color.l
EndStructure

Global Dim vPort(4);
Global Dim fontBase(25)   ;array of locations to font bases
Global fontbase.l         ;global location of currently used fontbase
;Global TextColor.l
Global glColorKey.l
Global console;Console Window Id
Global wm_close
Global base
Global Cube=2
Global msg.MSG
Global done.b
Global swidth.l ;screen width (Note: added code to print window size)
Global sheight.l ;screen height
Global Dim sprite.spriteinfo(60000)
Global Dim texture(100)
Global font.l           ;global handle to the font being used
Global texture.l
Global SpriteList.l
Global NumberOfSprites.l
Global hDC.l ;Private GDI Device Context
Global hRC.l ;Permanent Rendering Context
Global hWnd.l ;Holds Our Window Handle
Global wcRegistered  ;flag to tell if window class has been registered.  When re-creating windows do not re-register window class, will cause errors.
Global hInstance.l ;Holds The Instance Of The Application
Global fullscreen.l
Global width.l
Global height.l
Global newimageHeight.l
Global newimageWidth.l
Global imagewidth.l
Global imageheight.l
Global DMsaved.DEVMODE ;Saves The Previous Screen Settings
Global Dim keys.b(256) ;Array Used For The Keyboard Routine
Global Dim gltexture.l(1000) ;Stores Texture Objects
Global Dim *hBMP.BITMAPINFOHEADER(1000) ;Storage Space For Texture.  This needs to be dynamic and somewhere else
Global PerformanceFrequency.q
Global TimerResult.q
Global status2d.l
Global GLWindow.GLWindowInfo ;Define our window information structure
Global PerformanceFrequency.q
Global TimerResult.q
QueryPerformanceFrequency_(@PerformanceFrequency)
;performancefrequency=performancefrequency/10000

Global gCurrentUsage.d
Procedure.d GetTimer()

  QueryPerformanceCounter_(@timerresult)
tresult.d=(timerresult/performancefrequency)
  ProcedureReturn tresult;ElapsedMilliseconds()*10;
EndProcedure

Structure textinfo
  posx.l
  posy.l
  string.s[255]
  red.l
  green.l
  blue.l
  listBase.l      ;location of display list base - always the global fontbase from text()
EndStructure

Structure FontInfo                  ; will hold font information to pass to clipping procedure (Extract_Fonts())
  ImageMap.l                        ; holds image number of sprite map
  ClippingWidth.l                   ; how wide is each font
  ClippingHeight.l                  ; how tall is each font
  BeginOfSequence.l                 ; starting sequence number of letters
  FontColor.l                       ; holds RGB of text color
  TransparentColor.l                ; transparent color of font sprite map - usually rgb(255,255,255)
  LetterArray.l[100]                ; array of Image #'s of the letters - accessed easily by the above enumeration ie #_X = Image # for X, #x = Image # for x
EndStructure


Global Fullscreen ;Are we in Fullscreen?  Different Flipbuffer state if so
Global ScreenFPSCounter ;fps counter
Global StartFPSCounter  ; The start of the fps counter routine
Global BackDropColor ; Current Backdrop Color
Global NumberOfSprites.l
Global Dim SpriteIndex.l(60000)
Global Dim SpriteContainer.Spriteinfo(60000)
Global Dim strings.textinfo(10000)
Global Dim WidthArray(100)
Global TextCounter.l



; IDE Options = PureBasic 4.51 (Windows - x86)
; CursorPosition = 10
; Folding = -